<template>
	<view class="wf-box" :style="{ paddingTop: totalheight }">
		<HeadNav titleName="我的设置" :topheight="navBarHeight"></HeadNav>
		
		<view class="main">
			<view class="back-warp">
				<view class="back-lt">
					<view class="back-up">备份您的钱包</view>
					<view class="back-sub">我们强烈建议您备份钱包</view>
				</view>
				<view class="back-rt" @click="jumpSecure">
					立即备份
				</view>
			</view>
			
			<view class="ability-box">
				<view class="ability-item" @click="jumpCollect()">
					<image src="../../static/img/demo-04.png" class="adility-icon"></image>
					
					<view class="adility-info">
						<view class="info-tit">Wallet</view>
						<!-- <view class="info-addurl">0x6c9221...01Ee96c23C5BFAC</view> -->
					</view>
					
					<view class="adility-rt">
						<image src="../../static/img/chat-21.png" class="ady-ewm"></image>
						<image src="../../static/img/chat-32.png" class="ady-more"></image>
					</view>
				</view>
				
				<!-- jumpMeWallet -->
				<view class="ability-item aic-item" style="border-bottom: none;" @click="prompt">
					<image src="../../static/img/me-49.png" class="adility-icon"></image>
					
					<view class="adility-info">
						更改/添加钱包
					</view>
					
					<view class="adility-rt">
						<text>0x6c9221...01Ee96</text>
						<image src="../../static/img/chat-32.png" class="ady-more"></image>
					</view>
				</view>
			</view>
			
			<view class="ability-box pd-box">
				<view class="ability-item aic-item" @click="prompt">
					<image src="../../static/img/me-50.png" class="adility-icon"></image>
					
					<view class="adility-info">
						重命名此钱包
					</view>
					
					<view class="adility-rt">
						<image src="../../static/img/chat-32.png" class="ady-more"></image>
					</view>
				</view>
				
				<view class="ability-item aic-item" @click="openPopup">
					<image src="../../static/img/me-52.png" class="adility-icon"></image>
					
					<view class="adility-info">
						备份助记词
					</view>
					
					<view class="adility-rt">
						<image src="../../static/img/chat-32.png" class="ady-more"></image>
					</view>
				</view>
			</view>
			
			<view class="ability-box pd-box">
				<!-- jumpLink -->
				<view class="ability-item aic-item" @click="prompt">
					<image src="../../static/img/me-53.png" class="adility-icon"></image>
					
					<view class="adility-info">
						钱包授权
					</view>
					
					<view class="adility-rt">
						<image src="../../static/img/chat-32.png" class="ady-more"></image>
					</view>
				</view>
				
				<!-- jumpCurrency -->
				<view class="ability-item aic-item" @click="prompt">
					<image src="../../static/img/me-54.png" class="adility-icon"></image>
					
					<view class="adility-info">
						更改货币
					</view>
					
					<view class="adility-rt">
						<text>USD</text>
						<image src="../../static/img/chat-32.png" class="ady-more"></image>
					</view>
				</view>
				
				<!-- jumpNode -->
				<view class="ability-item aic-item" @click="prompt">
					<image src="../../static/img/me-55.png" class="adility-icon"></image>
					
					<view class="adility-info">
						节点设置
					</view>
					
					<view class="adility-rt">
						<image src="../../static/img/chat-32.png" class="ady-more"></image>
					</view>
				</view>
			</view>
		</view>
		
		<uni-popup ref="popup" type="center">
			<view class="popup-box">
				<view class="popup-title">请输入密码</view>
				<view class="popup-sub">
					<view>
						<input type="password" placeholder="请输入钱包密码" v-model="password">
					</view>
					
				</view>
				<view class="popup-footer">
					<view class="cancle" @click="closePopup()">取消</view>
					<view class="confim" @click="confim">确认</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import { throttle } from '@/utils/common.js'
	import { checkPsdApi } from '@/api/api.js'
	import navBarMixin from '@/mixin/navBarMixin.js'
	import HeadNav from "@/components/HeadNav"
	export default {
		data() {
			return {
				password: '',
			}
		},
		mixins: [navBarMixin],
		components: {
			HeadNav
		},
		methods: {
			back() {
				uni.navigateBack()
			},
			prompt() {
				uni.showToast({
					title: '敬请期待',
					icon: 'none'
				})
			},
			
			jumpSecure() {
				uni.navigateTo({
					url: '/pages/me/secure'
				})
			},
			jumpCollect() {
				uni.navigateTo({
					url: '/pages/me/collection'
				})
			},
			
			jumpMeWallet() {
				uni.navigateTo({
					url: '/pages/me/meWallet'
				})
			},
			
			jumpLink() {
				uni.navigateTo({
					url: '/pages/me/linkWallet'
				})
			},
			
			jumpCurrency() {
				uni.navigateTo({
					url: '/pages/me/currency'
				})
			},
			
			jumpNode() {
				uni.navigateTo({
					url: '/pages/me/nodeList'
				})
			},
			
			openPopup() {
				this.$refs.popup.open()
			},
			closePopup() {
				this.$refs.popup.close()
			},
			confim() {
				throttle(async() => {
					const res = await checkPsdApi({
						password: this.password
					})
					if(!res.code) {
						const words = res.data.result
						
						uni.navigateTo({
							url: '/pages/me/meAid?wordArr=' + JSON.stringify(words)
						})
						this.closePopup()
						
					}else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				},4000)
				
				
				// console.log('点击确认')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.wf-box {
		overflow: hidden;
		padding-bottom: 36rpx;
		
		.main {
			padding: 0 30rpx;
			margin-top: 30rpx;
			.back-warp {
				display: flex;
				justify-content: space-between;
				align-items: center;
				height: 170rpx;
				padding: 30rpx;
				background: url('../../static/img/me-48.png') no-repeat;
				background-size: 100% 100%;
				box-sizing: border-box;
				.back-lt {
					display: flex;
					flex-direction: column;
					.back-up {
						font-size: 28rpx;
						color: #fff;
					}
					.back-sub {
						margin-top: auto;
						font-size: 22rpx;
						color: #fff;
					}
				}
				.back-rt {
					height: max-content;
					padding: 5px 20rpx;
					border-radius: 25rpx;
					font-size: 24rpx;
					background: #E5F0FF;
					color: #333;
				}
			}
			.ability-box {
				padding: 0 30rpx;
				margin-top: 30rpx;
				background: #fff;
				border-radius: 10rpx;
				.ability-item {
					display: flex;
					align-items: center;
					height: 118rpx;
					border-bottom: 2rpx solid #eee;
					.adility-icon {
						width: 64rpx;
						height: 64rpx;
					}
					.adility-info {
						margin-left: 20rpx;
						.info-tit {
							color: #333;
							font-size: 28rpx;
						}
						.info-addurl {
							font-size: 20rpx;
							color: #999;
						}
					}
					.adility-rt {
						margin-left: auto;
						display: flex;
						align-items: center;
						.ady-ewm {
							width: 48rpx;
							height: 48rpx;
						}
						text {
							font-size: 22rpx;
							color: #999;
						}
						
						.ady-more {
							margin-left: 20rpx;
							width: 10rpx;
							height: 20rpx;
						}
					}
				}
				.aic-item {
					.adility-icon {
						width: 48rpx;
						height: 48rpx;
					}
				}
				
				&.pd-box {
					padding-bottom: 40rpx;
				}
			}
		}
	
		.popup-box {
			width: 583rpx;
			height: 580rpx;
			border-radius: 20rpx;
			box-sizing: border-box;
			background: #fff;
			background: url('../../static/img/me-32.png') no-repeat;
			background-size: cover;
			overflow: hidden;
			.popup-title {
				font-size: 32rpx;
				color: #333;
				font-weight: bold;
				text-align: center;
				margin-top: 224rpx;
			}
			.popup-sub {
				margin-top: 36rpx;
				height: 80rpx;
				padding: 0 50rpx;
				
				view {
					height: 100%;
					padding: 0 40rpx;
					border-radius: 8rpx;
					background: #F4F4F4;
				}
				input {
					height: 100%;
					font-size: 24rpx;
					background: #F4F4F4;
				}
			}
			.popup-footer {
				display: flex;
				justify-content: space-between;
				margin-top: 50rpx;
				padding: 0 50rpx;
				.cancle {
					width: 200rpx;
					line-height: 76rpx;
					text-align: center;
					border: 2rpx solid #3F93FF;
					border-radius: 40rpx;
				}
				.confim {
					width: 200rpx;
					line-height: 76rpx;
					text-align: center;
					border-radius: 40rpx;
					background: #3F93FF;
					color: #fff;
				}
			}
		}
	}
</style>